<template>
	<view class="prolist">
		<view class="prolist_item" v-for="(item,index) in prolist" :key="item.id"  @click="switchProlistDetail(index)">
			<view class='prolist_cover'>
				<image :src="item.cover"></image>
			</view>
			<view class="prolist_info">
				<view class='prolist_title'>
					<text>{{item.title}}</text>
				</view>
				<view class='prolist_price'>
					<text>¥ {{item.price}}</text>
				</view>
				<view class='prolist_other'>
					<text class='prolist_conmment'>{{item.comment}}条评价</text>
					<text class='prolist_rate'>好评率{{item.rate}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import data_jhf from "../../utils/data_jhf.js"

	export default {
		data() {
			return {
				prolist: [],
				page: 1, // 当前请求的page
				size: 5, // 请求数据的size
				noData: false // 是否有更多数据
			}
		},
		methods: {
			switchProlistDetail(index){
				console.log('点击了详情的信息'+index)
				let item = this.prolist[index]
				uni.navigateTo({
					url:"../detail/detail?id="+item.id
				})

			}
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.title
			})
			uni.showLoading({
				title: "加载中"
			})
			setTimeout(() => {
				uni.hideLoading()
				this.prolist = data_jhf.productionsList
				console.log(this.prolist)
			}, 1000)
		},
		onPullDownRefresh() {
			setTimeout(() => {
				this.prolist = data_jhf.productionsList
				uni.stopPullDownRefresh()
			}, 1000)
		},
		onReachBottom() {
			setTimeout(() => {
				let data = this.prolist
				data.forEach(item => {
					this.prolist.push(item)
				})
			}, 1000)
		},

	}
</script>

<style>
	.prolist {
		display: flex;
		flex-direction: column;
		width: 100%;
		background-color: white;
	}

	.prolist_item {
		display: flex;
		align-items: center;
		padding: 20upx;
	}

	.prolist_cover {
		padding: 0;
		width: 520upx;
		height: 240upx;
		overflow: hidden;
	}

	.prolist_cover image {
		width: 100%;
		height: 100%;
	}

	.prolist_info {
		min-height: 240rpx;
		box-sizing: border-box;
		padding: 0 20rpx 16rpx 20rpx;
		overflow: hidden;
		border-bottom: 2rpx solid #e8e8ed;
	}

	.prolist_title {
		/* 用于处理文字x文本显示为两行,超过部分隐藏并使用省略号
		  修改 width 属性查看效果。 */
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		word-break: break-all;
		/*normal：使用浏览器默认的换行规则。break-all	 ：允许在单词内换行。keep-all	只能在半角空格或连字符处换行。  */
		text-overflow: ellipsis;
		/*超出部分的省略方式，ellipsis为省略号，clip切，还可以用字符串的形式*/
		height: 80rpx;
		overflow: hidden;
		margin-top: 16rpx;
		color: #333;
		font-size: 28rpx;
	}

	.prolist_price {
		margin-top: 26rpx;
		height: 36rpx;
		color: #e93b3d;
		min-width: 80rpx;
	}

	.prolist_other {
		font-size: 24rpx;
		height: 40rpx;
		padding: 12rpx 60rpx 4rpx 0;
		box-sizing: border-box;
		overflow: hidden;
		color: #999;
	}
</style>
